<?php echo View::factory('admin/common/breadcrumbs')->set('breadcrumbs', $breadcrumbs)->render(); ?>
<div class="page-content">
    <div class="page-header">
        <h1>
            Add User      
        </h1>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->
            <div class="row-fluid">
                <div class="span12">
                    <div class="widget-box">
                        <div class="widget-header widget-header-blue widget-header-flat">

                        </div>

                        <div class="widget-body">
                            <div class="widget-main">
                                <div class="step-content row-fluid position-relative" id="step-container">
                                    <form autocomplete="off" class="form-horizontal" id="validation-form" method="post">


                                        <div class="hr hr-dotted"></div>
                                        <h3 class="lighter block green">Personal Information</h3>
                                        <div class="form-group">
                                            <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="password">Outside Access:</label>

                                            <div class="col-xs-12 col-sm-9">
                                                <div class="clearfix">
                                                    <div>
                                                        <label class="blue">
                                                            <input name="outsideaccess" <?= $en_user->getoutsideaccess() == 0 ? 'checked' : '' ?> value="0" type="radio" class="ace" />
                                                            <span class="lbl"> No</span>
                                                        </label>
                                                        &nbsp;
                                                        <label class="blue">
                                                            <input name="outsideaccess" <?= $en_user->getoutsideaccess() == 1 ? 'checked' : '' ?>  value="1" type="radio" class="ace" />
                                                            <span class="lbl"> Yes</span>
                                                        </label>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="space-2"></div>
                                        

                                        <div class="form-group">
                                            <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="password2">Active:</label>

                                            <div class="col-xs-12 col-sm-9">
                                                <div>
                                                    <label class="blue">
                                                        <input name="active" <?= $en_user->getactive() == 0 ? 'checked' : '' ?> value="0" type="radio" class="ace" />
                                                        <span class="lbl"> No</span>
                                                    </label>
                                                    &nbsp;
                                                    <label class="blue">
                                                        <input name="active" <?= $en_user->getactive() == 1 ? 'checked' : '' ?>  value="1" type="radio" class="ace" />
                                                        <span class="lbl"> Yes</span>
                                                    </label>
                                                </div>
                                            </div>
                                        </div>

                                        

                                        <div class="space-2"></div>

                                        <div class="form-group">
                                            <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="password2">Gender:</label>

                                            <div class="col-xs-12 col-sm-9">
                                                <div>
                                                    <label class="blue">
                                                        <input name="gender" <?= $en_user->getgender() == 1 ? 'checked' : '' ?> value="1" type="radio" class="ace" />
                                                        <span class="lbl"> Male</span>
                                                    </label>
                                                    &nbsp;
                                                    <label class="blue">
                                                        <input name="gender" <?= $en_user->getgender() == 2 ? 'checked' : '' ?>  value="2" type="radio" class="ace" />
                                                        <span class="lbl"> Female</span>
                                                    </label>
                                                </div>
                                            </div>
                                        </div>

                                        

                                        <div class="space-2"></div>

                                        <div class="form-group">
                                            <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="phone">Full Name<span class="red">*</span>:</label>

                                            <div class="col-xs-12 col-sm-9">
                                                <div class="clearfix">
                                                    <input type="text" placeholder="Enter text First Name" id="fname" name="fname" class="col-xs-12 col-sm-5" value="<?= $en_user->getFname() ?>" />
                                                </div>
                                            </div>
                                        </div>

                                        

                                        <div class="space-2"></div>

                                        <div class="form-group">
                                            <label class="control-label col-xs-12 col-sm-3 no-padding-right">Email:</label>

                                            <div class="col-xs-12 col-sm-9">
                                                <div class="clearfix">
                                                    <input type="text" placeholder="Enter text Email" id="email" name="email" class="col-xs-12 col-sm-5" value="<?= $en_user->getEmail() ?>" />
                                                </div>
                                            </div>
                                        </div>

                                        <div class="space-2"></div>

                                        <div class="form-group">
                                            <label class="control-label col-xs-12 col-sm-3 no-padding-right">Phone: </label>
                                            <div class="col-xs-12 col-sm-9">
                                                <div class="clearfix">
                                                    <input type="text" placeholder="Enter text Phone" id="phone" name="phone" class="col-xs-12 col-sm-5" value="<?= $en_user->getPhone() ?>" />
                                                </div>
                                            </div>
                                        </div>

                                        

                                        <div class="space-2"></div>

                                        <div class="form-group" style="display: none;">
                                            <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="platform">Image:</label>
                                            <?php ?>
                                            <div class="col-xs-12 col-sm-9">
                                                <div class="clearfix">
                                                    <div id="uploadavatar"></div>
                                                    <br>
                                                    <img style="width: 70px;" id="imageuploadcontent" style="display: none;" />
                                                    <input type="hidden" name="imagename" id="imagename"  />
                                                </div>
                                            </div>
                                        </div>

                                        
                                        
                                        <div class="space-2"></div>
                                        <div class="form-group">
                                            <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="comment">DOB:</label>

                                            <div class="col-xs-12 col-sm-9">
                                                <div class="clearfix">
                                                    <input class="col-xs-12 col-sm-5" type="text" name="dob" placeholder="Enter text DOB" id="dob" value="<?= $en_user->getdob() ?>" />mm/dd/yyyy
                                                </div>
                                            </div>
                                        </div>
                                        <div id="divEmployees">
                                            <div class="hr hr-dotted"></div>
                                            <h3 class="lighter block green">Account Information</h3>
                                            <i>*Fields below are used for Employees</i>
                                            <div class="form-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="username">Username<span class="red">*</span>:</label>

                                                <div class="col-xs-12 col-sm-9">
                                                    <div class="clearfix">
                                                        <input autocomplete="false" class="col-xs-12 col-sm-5" type="text" name="username" placeholder="Enter text Username" id="username" value="<?= $en_user->getusername() ?>" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="space-2"></div>
                                            <div class="form-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="username">Distributor ID<span class="red">*</span>:</label>

                                                <div class="col-xs-12 col-sm-9">
                                                    <div class="clearfix">
                                                        <input autocomplete="false" class="col-xs-12 col-sm-5" type="text" name="location_id" placeholder="Enter text Username" id="location_id" value="<?= $en_user->getlocation_id() ?>" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="space-2"></div>
                                            <div class="form-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="password">Password<span class="red">*</span>:</label>

                                                <div class="col-xs-12 col-sm-9">
                                                    <div class="clearfix">
                                                        <input autocomplete="false" class="col-xs-12 col-sm-5" type="password" name="password" placeholder="Enter text Password" id="password" value="<?= $en_user->getPassword() ?>" />
                                                    </div>
                                                </div>
                                            </div>
                                            
                                            <div class="space-2"></div>

                                            <div class="form-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="office_location">Address:</label>

                                                <div class="col-xs-12 col-sm-9">
                                                    <div class="clearfix">
                                                        <input type="text" class="col-xs-12 col-sm-5" maxlength="1000" placeholder="Enter text Office Location" value="<?= $en_user->getoffice_location() ?>" name="office_location" id="office_location" />
                                                    </div>
                                                </div>
                                            </div>

                                            

                                        </div>

                                        <div id="divEmployeesGroupPermission" style="display: none;">
                                            <div class="hr hr-dotted"></div>
                                            <h3 class="lighter block green">Group Permission</h3>
                                            <i>*Fields below are used for Employees</i>
                                            <div class="space-2"></div>
                                            <div class="form-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="email">Supor Admin:</label>
                                                <div class="col-xs-12 col-sm-9">
                                                    <div class="clearfix">

                                                        <div>
                                                            <label class="blue">
                                                                <input name="admin_supor" <?= (int)$en_user->getusertype() == 0 ? 'checked' : '' ?> value="0" type="radio" class="ace usertype" />
                                                                <span class="lbl"> No</span>
                                                            </label>
                                                            &nbsp;
                                                            <label class="blue">
                                                                <input name="admin_supor" <?= (int)$en_user->getusertype() == 1 ? 'checked' : '' ?>  value="1" type="radio" class="ace usertype usertypeEmployee" />
                                                                <span class="lbl"> Yes</span>
                                                            </label>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="permission">Group <span class="red">*</span>:</label>

                                                <div class="controls" style="margin-left: 280px;padding: 10px 0;">
                                                    <select id='group_id' name="group_id[]" multiple='multiple'>
                                                        <?php
                                                        if (!empty($a_group[0])) {
                                                            foreach ($a_group as $o_group) {
                                                                $o_entity_group = $o_group->get_data();
                                                                $selected = "";
                                                                if (!empty($a_group_id) && is_array($a_group_id) && in_array($o_entity_group->getId(), $a_group_id)) {
                                                                    $selected = "selected";
                                                                }
                                                                echo '<option ' . $selected . ' value="' . $o_entity_group->getId() . '">' . $o_entity_group->getName() . '</option>';
                                                            }
                                                        }
                                                        ?>
                                                    </select>
                                                </div>
                                                <div class="controls" style="margin-left: 272px;padding: 10px 0;">
                                                    <?= Form::input('selectallgroup', 'Select All', array('type' => 'button', 'id' => 'selectallgroup', 'class' => 'btn tip-bottom')) ?>
                                                    <?= Form::input('deselectallgroup', 'Deselect All', array('type' => 'button', 'id' => 'deselectallgroup', 'class' => 'btn tip-bottom')) ?>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="permission">Permission <span class="red">*</span>:</label>

                                                <div class="controls" style="margin-left: 280px;padding: 10px 0;">
                                                    <select id='permission_id' name="permission_id[]" multiple='multiple'>
                                                        <?php
                                                        if (!empty($a_p_controller[0])) {
                                                            foreach ($a_p_controller as $o_pc) {
                                                                $o_emtity_pc = $o_pc->get_data();
                                                                $s_per = $o_emtity_pc->get_Permission();
                                                                $a_data_per = $s_per->query_all();
                                                                ?>
                                                                <optgroup label='<?= $o_emtity_pc->getDescription() ?>'>
                                                                    <?php
                                                                    if (!empty($a_data_per[0])) {
                                                                        foreach ($a_data_per as $o_data_per) {
                                                                            $o_entity_per = $o_data_per->get_data();
                                                                            $selected = "";
                                                                            if (isset($a_post['permission_id']) && is_array($a_post['permission_id']) && in_array($o_entity_per->getId(), $a_post['permission_id'])) {
                                                                                $selected = "selected";
                                                                            }
                                                                            echo "<option $selected value='" . $o_entity_per->getId() . "'>" . $o_entity_per->getDescription() . "</option>";
                                                                        }
                                                                    }
                                                                    ?>
                                                                </optgroup>
                                                                <?php
                                                            }
                                                        }
                                                        ?>
                                                    </select>
                                                </div>
                                                <div class="controls" style="margin-left: 272px;padding: 10px 0;">
                                                    <?= Form::input('selectall', 'Select All', array('type' => 'button', 'id' => 'selectallper', 'class' => 'btn tip-bottom')) ?>
                                                    <?= Form::input('deselectall', 'Deselect All', array('type' => 'button', 'id' => 'deselectallper', 'class' => 'btn tip-bottom')) ?>
                                                </div>
                                            </div>
                                        </div>
                                        
                                        <div class="space-8"></div>

                                    </form>
                                </div>

                                <hr />
                                <div class="row-fluid wizard-actions">
                                    <button class="btn btn-prev" onclick="window.location = '<?= URL::base() ?>admin/user/list?act=0';">
                                        <i class="icon-arrow-left"></i>
                                        Cancel
                                    </button>

                                    <button id="cmdsave" class="btn btn-success btn-next" data-last="Finish ">
                                        Submit
                                        <i class="icon-arrow-right icon-on-right"></i>
                                    </button>
                                    <img id="loading" style="display: none;" src="<?= $url_base_theme . '/img/loading_1.gif' ?>" />
                                </div>
                            </div><!-- /widget-main -->
                        </div><!-- /widget-body -->
                    </div>
                </div>
            </div>
            <!-- PAGE CONTENT ENDS -->
        </div><!-- /.col -->
    </div><!-- /.row -->
</div>
<script>
    var _user_add = user_add.CreateObject({
        id: '_user_add',
        FOLDER_UPLOAD_TEMP: '<?= Controller_Helper_Constant::FOLDER_TEMP ?>',
       
    });

</script>